﻿
Imports ADOEntityAMLO101

Partial Class Form_RptAmlo1_01
    Inherits System.Web.UI.Page

    Dim AmloEntity As AMLO101Entities
    Dim clsDateFormat As New clsDateFormat
    Dim clsMasterDropDown As clsMasterDropDown
    Dim strTempName As String = ""

    'Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
    '    Response.AddHeader("Cache-control", "no-store, must-revalidate, private,no-cache")
    '    Response.AddHeader("Pragma", "no-cache")
    '    Response.AddHeader("Expires", "0")
    'End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


        AmloEntity = New AMLO101Entities
        clsMasterDropDown = New clsMasterDropDown
        'Dim strRptSeq As String = Request.Item("RptSeq")
        'Dim strRptIdx As String = Request.Item("RptIdx")
        Dim strRptSeq As String = Request.QueryString("RptSeq")
        Dim strRptIdx As String = Request.QueryString("RptIdx")
        '  Dim strStatus As String = Request.Item("RPTStatus")
       

        Try
            'If strStatus = "" Then
            '    ScriptManager.RegisterStartupScript(Me, Me.GetType(), "clientScript", "window.close();", True)

            'Else
            If Not (strRptSeq = "") Then
                Dim sql = (From tblRRPT In AmloEntity.AMLO101 Join tblRRPTDEtail In AmloEntity.AMLODETAIL101 On tblRRPT.RPTSEQ Equals tblRRPTDEtail.RPTSEQ
                        Where tblRRPT.RPTSEQ = strRptSeq And (tblRRPTDEtail.RPTIDX = 1 Or tblRRPTDEtail.RPTIDX = strRptIdx)).ToList
                Dim countRow As Integer = sql.Count

                Dim qryRpt = (From tblRPT In AmloEntity.AMLO101 Where tblRPT.RPTSEQ = strRptSeq).ToList

                Dim qryRptDetail = (From tblRRPTDEtail In AmloEntity.AMLODETAIL101
                                    Where tblRRPTDEtail.RPTSEQ = strRptSeq And (tblRRPTDEtail.RPTIDX = 1 Or tblRRPTDEtail.RPTIDX = strRptIdx)).ToList
                setRptPart1(qryRpt, qryRptDetail)
                setRptPart2(qryRptDetail)
                setRptPart3(qryRpt)
            End If
            Response.Write("<script>")
            Response.Write("window.print()")
            Response.Write("</script>")
            ' End If

        Catch ex As Exception

        End Try
      
    End Sub

    Private Sub setRptPart1(ByVal RptMaster As IList(Of AMLO101), ByVal RptMasterCus As IList(Of AMLODETAIL101))
        Dim strTemp As String = ""
        Dim arrTemp As String() = Nothing

        'ทำการตัด HGBCode เป็นช่องๆ
        Try


            lblGHBCode1.Text = 0
            lblGHBCode2.Text = 3
            lblGHBCode3.Text = 3
            'ทำการตัด BranchCode เป็นช่องๆ
            strTemp = RptMaster(0).BRANCHCODE
            'branchCode1.Text = subStringText(RptMaster(0).BRANCHCODE, 1)
            'branchCode2.Text = subStringText(RptMaster(0).BRANCHCODE, 2)
            branchCode3.Text = subStringText(RptMaster(0).BRANCHCODE, 1)
            branchCode4.Text = subStringText(RptMaster(0).BRANCHCODE, 2)
            branchCode5.Text = subStringText(RptMaster(0).BRANCHCODE, 3)
            'ทำการตัด lblYear เป็นช่องๆ
            strTemp = RptMaster(0).RPTYEAR
            lblYear1.Text = subStringText(RptMaster(0).RPTYEAR, 1)
            lblYear2.Text = subStringText(RptMaster(0).RPTYEAR, 2)
            'ทำการใส่ค่า rptNo
            lblRptNo.Text = RptMaster(0).RPTNO

            'ทำการ set ค่า RptRev
            If (RptMaster(0).RPTREV = 0) Then
                lblRev0.Text = "x"
                lblRev1.Text = ""
                lblRevOther.Text = "0"
            Else
                lblRev0.Text = ""
                lblRev1.Text = "x"
                lblRevOther.Text = RptMaster(0).RPTREV
            End If


            'เป็นการ set ค่า RPTDate
            lblRptDate.Text = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, RptMaster(0).RPTDATE)




            'เป็นการ set uniqueID
            Dim cusToTran = (RptMasterCus.Where(Function(t) t.RPTIDX = 1)).ToList

            lblUniqueID1.Text = subStringText(cusToTran(0).UNIQUEID, 1)
            lblUniqueID2.Text = subStringText(cusToTran(0).UNIQUEID, 2)
            lblUniqueID3.Text = subStringText(cusToTran(0).UNIQUEID, 3)
            lblUniqueID4.Text = subStringText(cusToTran(0).UNIQUEID, 4)
            lblUniqueID5.Text = subStringText(cusToTran(0).UNIQUEID, 5)
            lblUniqueID6.Text = subStringText(cusToTran(0).UNIQUEID, 6)
            lblUniqueID7.Text = subStringText(cusToTran(0).UNIQUEID, 7)
            lblUniqueID8.Text = subStringText(cusToTran(0).UNIQUEID, 8)
            lblUniqueID9.Text = subStringText(cusToTran(0).UNIQUEID, 9)
            lblUniqueID10.Text = subStringText(cusToTran(0).UNIQUEID, 10)
            lblUniqueID11.Text = subStringText(cusToTran(0).UNIQUEID, 11)
            lblUniqueID12.Text = subStringText(cusToTran(0).UNIQUEID, 12)
            lblUniqueID13.Text = subStringText(cusToTran(0).UNIQUEID, 13)

            If (cusToTran(0).RPTIDXTYPE = 1) Then
                lblRptIdxType1.Text = "x"
            ElseIf (cusToTran(0).RPTIDXTYPE = 2) Then
                lblRptIdxType2.Text = "x"
            End If

            'เป็นการ  set name
            Try
        

                strTempName = ""
                If Not (cusToTran(0).PREFIX = "-" Or cusToTran(0).PREFIX = Nothing) Then
                    If (strTempName = "") Then
                        strTempName = strTempName + cusToTran(0).PREFIX
                    Else
                        strTempName = strTempName + " " + cusToTran(0).PREFIX
                    End If
                End If

                If Not (cusToTran(0).FIRSTNAME = "-" Or cusToTran(0).FIRSTNAME = "") Then
                    If (strTempName = "") Then
                        strTempName = strTempName + cusToTran(0).FIRSTNAME
                    Else
                        strTempName = strTempName + " " + cusToTran(0).FIRSTNAME
                    End If
                End If

                If Not (cusToTran(0).MIDNAME = "-" Or cusToTran(0).MIDNAME = "") Then
                    If (strTempName = "") Then
                        strTempName = strTempName + cusToTran(0).MIDNAME
                    Else
                        strTempName = strTempName + " " + cusToTran(0).MIDNAME
                    End If
                End If

                If Not (cusToTran(0).LASTNAME = "-" Or cusToTran(0).LASTNAME = "") Then
                    If (strTempName = "") Then
                        strTempName = strTempName + cusToTran(0).LASTNAME
                    Else
                        strTempName = strTempName + " " + cusToTran(0).LASTNAME
                    End If
                End If
                lblFullName.Text = strTempName

            Catch ex As Exception
                lblFullName.Text = cusToTran(0).FIRSTNAME & " " & cusToTran(0).LASTNAME
            End Try


            'เป็นการ set formal 
            lblFormalAddr.Text = cusToTran(0).FORMALADDR
            lblFormalPhone.Text = cusToTran(0).FORMALPHONE
            lblFormalFax.Text = cusToTran(0).FORMALFAX

            'เป็นการ set occupation, work
            If (cusToTran(0).OCCUPATIONTYPE = Nothing) Then
                lblOccupationType.Text = ""
            ElseIf (cusToTran(0).OCCUPATIONTYPE = 99) Then
                lblOccupationType.Text = ""
                lblOccupationTypeOther.Text = cusToTran(0).OCCUPATIONTYPEOTHER
                If (cusToTran(0).OCCUPATIONTYPEOTHER.Length > 18) Then
                    lblOccupationTypeOther.Font.Size = FontSize.Small
                End If
            Else
                lblOccupationType.Text = clsMasterDropDown.getOfficeOcc_AMLO101(AmloEntity, cusToTran(0).OCCUPATIONTYPE)
            End If



            lblWorkAddr.Text = cusToTran(0).WORKADDR '///38
            If (cusToTran(0).WORKADDR.Length > 37) Then
                lblWorkAddr.Font.Size = FontSize.Small
            End If


            lblWorkPhone.Text = cusToTran(0).WORKPHONE

            'เป็นการ set สถานที่ติดต่อสะดวก
            lblContactAddr.Text = cusToTran(0).CONTACTADDR
            lblContactPhone.Text = cusToTran(0).CONTACTPHONE
            lblContactFax.Text = cusToTran(0).CONTACTFAX

            'เป็นการ set type หลักฐาน
            Try
                If Not (cusToTran(0).CUSTIDTYPE Is Nothing) Then

                    If (CInt(cusToTran(0).CUSTIDTYPE).ToString = "1") Then
                        lblCustype1.Text = "x"
                    ElseIf (CInt(cusToTran(0).CUSTIDTYPE).ToString = "6") Then
                        lblCustype1.Text = "x"
                    ElseIf (CInt(cusToTran(0).CUSTIDTYPE).ToString = "3") Then
                        lblCusType2.Text = "x"
                    ElseIf (CInt(cusToTran(0).CUSTIDTYPE).ToString = "4") Then
                        lblCusType3.Text = "x"
                    ElseIf (CInt(cusToTran(0).CUSTIDTYPE).ToString = "99") Then
                        lblCusType4.Text = "x"
                        lblCusTypeOther.Text = cusToTran(0).CUSTIDTYPEOTHER
                    Else
                        lblCusType4.Text = "x"
                        lblCusTypeOther.Text = clsMasterDropDown.getTypeID_AMLO101(AmloEntity, cusToTran(0).CUSTIDTYPE)
                    End If
                End If
            Catch ex As Exception

            End Try


            lblCusId.Text = cusToTran(0).CUSTID
            lblEvby.Text = cusToTran(0).EVBY
            If (cusToTran(0).EVGENTEXT = Nothing) Then
                lblEvGen.Text = ""
            ElseIf (cusToTran(0).EVGENTEXT = "-") Then
                lblEvGen.Text = "-"
            Else
                Try
                    'lblEvGen.Text = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, cusToTran(0).EVGEN)
                    lblEvGen.Text = clsDateFormat.convertIntToDate(clsDateFormat.enmDateCultureInfo.Th, cusToTran(0).EVGENTEXT)
                Catch ex As Exception

                End Try
            End If

            If (cusToTran(0).EVEXPIRETEXT = Nothing) Then
                lblEvExpire.Text = ""
            ElseIf (cusToTran(0).EVEXPIRETEXT = "-") Then
                lblEvExpire.Text = "-"
            Else
                Try
                    lblEvExpire.Text = clsDateFormat.convertIntToDate(clsDateFormat.enmDateCultureInfo.Th, cusToTran(0).EVEXPIRETEXT)
                Catch ex As Exception

                End Try
            End If


        Catch ex As Exception

        End Try


    End Sub

    'Private Sub setRptPart2(ByVal RptDetailCus As IList(Of RRPTDETAIL))
    '    Dim RptDetailCusCon = RptDetailCus.Where(Function(t) t.RPTIDX <> 1)
    '    If (RptDetailCus(0).RPTIDXTYPE = 3) Then
    '        lblPart2_RptIdxType1.Text = "x"
    '    ElseIf (RptDetailCus(0).RPTIDXTYPE = 4) Then
    '        lblPart2_RptIdxType2.Text = "x"
    '    ElseIf (RptDetailCus(0).RPTIDXTYPE = 5) Then
    '        lblPart2_RptIdxType3.Text = "x"
    '    End If

    '    lblPart2_UniqueId1.Text = subStringText(RptDetailCus(0).UNIQUEID, 1)
    '    lblPart2_UniqueId2.Text = subStringText(RptDetailCus(0).UNIQUEID, 2)
    '    lblPart2_UniqueId3.Text = subStringText(RptDetailCus(0).UNIQUEID, 3)
    '    lblPart2_UniqueId4.Text = subStringText(RptDetailCus(0).UNIQUEID, 4)
    '    lblPart2_UniqueId5.Text = subStringText(RptDetailCus(0).UNIQUEID, 5)
    '    lblPart2_UniqueId6.Text = subStringText(RptDetailCus(0).UNIQUEID, 6)
    '    lblPart2_UniqueId7.Text = subStringText(RptDetailCus(0).UNIQUEID, 7)
    '    lblPart2_UniqueId8.Text = subStringText(RptDetailCus(0).UNIQUEID, 8)
    '    lblPart2_UniqueId9.Text = subStringText(RptDetailCus(0).UNIQUEID, 9)
    '    lblPart2_UniqueId10.Text = subStringText(RptDetailCus(0).UNIQUEID, 10)
    '    lblPart2_UniqueId11.Text = subStringText(RptDetailCus(0).UNIQUEID, 11)
    '    lblPart2_UniqueId12.Text = subStringText(RptDetailCus(0).UNIQUEID, 12)
    '    lblPart2_UniqueId13.Text = subStringText(RptDetailCus(0).UNIQUEID, 13)

    '    Try
    '        If (RptDetailCus(0).MIDNAME = "-") Then
    '            lblPart2_FullName.Text = RptDetailCus(0).FIRSTNAME & " " & RptDetailCus(0).LASTNAME
    '        Else
    '            lblPart2_FullName.Text = RptDetailCus(0).FIRSTNAME & " " & RptDetailCus(0).MIDNAME & " " & RptDetailCus(0).LASTNAME
    '        End If
    '    Catch ex As Exception
    '        lblPart2_FullName.Text = RptDetailCus(0).FIRSTNAME & " " & RptDetailCus(0).LASTNAME
    '    End Try


    '    lblPart2_FormalAddr.Text = RptDetailCus(0).FORMALADDR
    '    lblPart2_formalPhone.Text = RptDetailCus(0).FORMALPHONE
    '    lblPart2_formalFax.Text = RptDetailCus(0).FORMALFAX

    '    If (RptDetailCus(0).OCCUPATIONTYPE = 0) Then
    '        lblPart2_OccupationType.Text = ""
    '    ElseIf (RptDetailCus(0).OCCUPATIONTYPE = 1) Then
    '        lblPart2_OccupationType.Text = "เจ้าของกิจการ"
    '    ElseIf (RptDetailCus(0).OCCUPATIONTYPE = 2) Then
    '        lblPart2_OccupationType.Text = "ข้าราชการ"
    '    ElseIf (RptDetailCus(0).OCCUPATIONTYPE = 3) Then
    '        lblPart2_OccupationType.Text = "รับจ้าง"
    '    ElseIf (RptDetailCus(0).OCCUPATIONTYPE = 4) Then
    '        lblPart2_OccupationType.Text = "พนักงานรัฐวิสาหกิจ"
    '    ElseIf (RptDetailCus(0).OCCUPATIONTYPE = 5) Then
    '        lblPart2_OccupationType.Text = "อาชีพอิสระ"
    '    ElseIf (RptDetailCus(0).OCCUPATIONTYPE = 6) Then
    '        lblPart2_OccupationType.Text = "นิสิต นักศึกษา"
    '    ElseIf (RptDetailCus(0).OCCUPATIONTYPE = 99) Then
    '        lblPart2_OccupationType.Text = ""
    '        lblPart2_OccupationTypeOther.Text = RptDetailCus(0).OCCUPATIONTYPEOTHER
    '    End If
    '    lblpart2_WorkAddr.Text = RptDetailCus(0).WORKADDR
    '    lblpart2_WorkPhone.Text = RptDetailCus(0).WORKPHONE

    '    If (RptDetailCus(0).BIZTYPE = 0) Then
    '        lblBizType.Text = "-"
    '    ElseIf (RptDetailCus(0).BIZTYPE = 1) Then
    '        lblBizType.Text = "ร้านค้า"
    '    ElseIf (RptDetailCus(0).BIZTYPE = 2) Then
    '        lblBizType.Text = "ร้านอาหาร"
    '    ElseIf (RptDetailCus(0).BIZTYPE = 3) Then
    '        lblBizType.Text = "โรงแรม"
    '    ElseIf (RptDetailCus(0).BIZTYPE = 4) Then
    '        lblBizType.Text = "โรงงาน"
    '    ElseIf (RptDetailCus(0).BIZTYPE = 5) Then
    '        lblBizType.Text = "บันเทิง"
    '    ElseIf (RptDetailCus(0).BIZTYPE = 6) Then
    '        lblBizType.Text = "อสังหาริมทรัพย์"
    '    ElseIf (RptDetailCus(0).BIZTYPE = 7) Then
    '        lblBizType.Text = "สถาบันการเงิน"
    '    ElseIf (RptDetailCus(0).BIZTYPE = 99) Then
    '        lblBizTypeOther.Text = RptDetailCus(0).BIZTYPEOTHER
    '    End If


    '    lblPart2_ContactAddr.Text = RptDetailCus(0).CONTACTADDR
    '    lblPart2_ContactPhone.Text = RptDetailCus(0).CONTACTPHONE
    '    lblPart2_ContactFax.Text = RptDetailCus(0).CONTACTFAX


    '    'เป็นการ set type หลักฐาน
    '    If (RptDetailCus(0).CUSTIDTYPE = 1) Then
    '        lblPart2_CusType1.Text = "x"
    '    ElseIf (RptDetailCus(0).CUSTIDTYPE = 2) Then
    '        lblPart2_CusType1.Text = "x"
    '    ElseIf (RptDetailCus(0).CUSTIDTYPE = 3) Then
    '        lblPart2_CusType1.Text = "x"
    '    ElseIf (RptDetailCus(0).CUSTIDTYPE = 4) Then
    '        lblPart2_CusType2.Text = "x"
    '    ElseIf (RptDetailCus(0).CUSTIDTYPE = 5) Then
    '        lblPart2_CusType3.Text = "x"
    '    ElseIf (RptDetailCus(0).CUSTIDTYPE = 6) Then
    '        lblPart2_CusType4.Text = "x"
    '    Else
    '        lblPart2_CusType4.Text = "x"
    '        lblPart2_CusTypeOther.Text = RptDetailCus(0).CUSTIDTYPEOTHER
    '    End If




    '    lblPart2_CusId.Text = RptDetailCus(0).CUSTID
    '    lblPart2_Evby.Text = RptDetailCus(0).EVBY
    '    lblPart2_EvGen.Text = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, RptDetailCus(0).EVGEN)
    '    lblPart2_EvExpire.Text = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, RptDetailCus(0).EVEXPIRE)




    'End Sub

    Private Sub setRptPart2(ByVal RptDetailCus As IList(Of AMLODETAIL101))
           Dim RptDetailCusWhere = RptDetailCus.Where(Function(t) t.RPTIDX <> 1)
        If Not (RptDetailCusWhere.Count = 0) Then

            If (RptDetailCusWhere(0).RPTIDXTYPE = 1) Then
                lblPart2_RptIdxType1.Text = "x"
            ElseIf (RptDetailCusWhere(0).RPTIDXTYPE = 2) Then
                lblPart2_RptIdxType2.Text = "x"
            ElseIf (RptDetailCusWhere(0).RPTIDXTYPE = 3) Then
                lblPart2_RptIdxType3.Text = "x"
            End If

            lblPart2_UniqueId1.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 1)
            lblPart2_UniqueId2.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 2)
            lblPart2_UniqueId3.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 3)
            lblPart2_UniqueId4.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 4)
            lblPart2_UniqueId5.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 5)
            lblPart2_UniqueId6.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 6)
            lblPart2_UniqueId7.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 7)
            lblPart2_UniqueId8.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 8)
            lblPart2_UniqueId9.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 9)
            lblPart2_UniqueId10.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 10)
            lblPart2_UniqueId11.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 11)
            lblPart2_UniqueId12.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 12)
            lblPart2_UniqueId13.Text = subStringText(RptDetailCusWhere(0).UNIQUEID, 13)

            Try
                If (RptDetailCusWhere(0).MIDNAME = "-") Then
                    lblPart2_FullName.Text = RptDetailCusWhere(0).FIRSTNAME & " " & RptDetailCusWhere(0).LASTNAME
                Else
                    lblPart2_FullName.Text = RptDetailCusWhere(0).FIRSTNAME & " " & RptDetailCusWhere(0).MIDNAME & " " & RptDetailCusWhere(0).LASTNAME
                End If
            Catch ex As Exception
                lblPart2_FullName.Text = RptDetailCusWhere(0).FIRSTNAME & " " & RptDetailCusWhere(0).LASTNAME
            End Try

            lblPart2_FormalAddr.Text = RptDetailCusWhere(0).FORMALADDR
            If (RptDetailCusWhere(0).FORMALADDR.Length > 50) Then
                lblPart2_FormalAddr.Text = RptDetailCusWhere(0).FORMALADDR.Substring(0, 48)
                lblPart2_FormalAddr0.Text = RptDetailCusWhere(0).FORMALADDR.Substring(48, (RptDetailCusWhere(0).FORMALADDR.Length) - 48)

            End If

            lblPart2_formalPhone.Text = RptDetailCusWhere(0).FORMALPHONE

            lblPart2_formalFax.Text = RptDetailCusWhere(0).FORMALFAX

            If (RptDetailCusWhere(0).OCCUPATIONTYPE = Nothing) Then
                lblPart2_OccupationType.Text = ""
            ElseIf (RptDetailCusWhere(0).OCCUPATIONTYPE = 99) Then
                lblPart2_OccupationType.Text = ""
                lblPart2_OccupationTypeOther.Text = RptDetailCusWhere(0).OCCUPATIONTYPEOTHER
                If (RptDetailCusWhere(0).OCCUPATIONTYPEOTHER.Length > 18) Then
                    lblPart2_OccupationTypeOther.Font.Size = FontSize.Small
                End If
            Else
                lblPart2_OccupationType.Text = clsMasterDropDown.getOfficeOcc_AMLO101(AmloEntity, RptDetailCusWhere(0).OCCUPATIONTYPE)
            End If


            lblpart2_WorkAddr.Text = RptDetailCusWhere(0).WORKADDR
            If (RptDetailCusWhere(0).WORKADDR.Length > 37) Then
                lblpart2_WorkAddr.Font.Size = FontSize.Small
            End If

            lblpart2_WorkPhone.Text = RptDetailCusWhere(0).WORKPHONE

            If (RptDetailCusWhere(0).BIZTYPE Is Nothing) Then
                If (RptDetailCusWhere(0).BIZTYPE = 99) Then
                    lblBizType.Text = ""
                    lblBizTypeOther.Text = RptDetailCusWhere(0).BIZTYPEOTHER
                Else
                    lblBizType.Text = clsMasterDropDown.getOfficeType_AMLO101(AmloEntity, RptDetailCusWhere(0).BIZTYPE)
                End If

            End If

            lblPart2_ContactAddr.Text = RptDetailCusWhere(0).CONTACTADDR
            lblPart2_ContactPhone.Text = RptDetailCusWhere(0).CONTACTPHONE
            lblPart2_ContactFax.Text = RptDetailCusWhere(0).CONTACTFAX


            'เป็นการ set type หลักฐาน
            Try
                If (CInt(RptDetailCusWhere(0).CUSTIDTYPE).ToString = "1") Then
                    lblPart2_CusType1.Text = "x"
                ElseIf (CInt(RptDetailCusWhere(0).CUSTIDTYPE).ToString = "6") Then
                    lblPart2_CusType1.Text = "x"
                ElseIf (CInt(RptDetailCusWhere(0).CUSTIDTYPE).ToString = "3") Then
                    lblPart2_CusType2.Text = "x"
                ElseIf (CInt(RptDetailCusWhere(0).CUSTIDTYPE).ToString = "4") Then
                    lblPart2_CusType3.Text = "x"
                ElseIf (CInt(RptDetailCusWhere(0).CUSTIDTYPE).ToString = "5") Then
                    lblPart2_CusType4.Text = "x"
                ElseIf (CInt(RptDetailCusWhere(0).CUSTIDTYPE).ToString = "99") Then
                    lblPart2_CusType5.Text = "x"
                Else
                    lblPart2_CusType5.Text = "x"
                    lblPart2_CusTypeOther.Text = clsMasterDropDown.getTypeID_AMLO101(AmloEntity, RptDetailCusWhere(0).CUSTIDTYPE)

                End If
            Catch ex As Exception

            End Try


            lblPart2_CusId.Text = RptDetailCusWhere(0).CUSTID
            lblPart2_Evby.Text = RptDetailCusWhere(0).EVBY

            If (RptDetailCusWhere(0).EVGENTEXT = Nothing) Then
                lblPart2_EvGen.Text = ""
            ElseIf (RptDetailCusWhere(0).EVGENTEXT = "-") Then
                lblPart2_EvGen.Text = "-"
            Else
                Try
                    ' lblPart2_EvGen.Text = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, RptDetailCusWhere(0).EVGEN)
                    lblPart2_EvGen.Text = clsDateFormat.convertIntToDate(clsDateFormat.enmDateCultureInfo.Th, RptDetailCusWhere(0).EVGENTEXT)

                Catch ex As Exception
                End Try

            End If

            If (RptDetailCusWhere(0).EVEXPIRETEXT = Nothing) Then
                lblPart2_EvExpire.Text = ""
            ElseIf (RptDetailCusWhere(0).EVEXPIRETEXT = "-") Then
                lblPart2_EvExpire.Text = "-"
            Else
                Try
                    'lblPart2_EvExpire.Text = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, RptDetailCusWhere(0).EVEXPIRE)
                    lblPart2_EvExpire.Text = clsDateFormat.convertIntToDate(clsDateFormat.enmDateCultureInfo.Th, RptDetailCusWhere(0).EVEXPIRETEXT)
                Catch ex As Exception
                End Try
            End If

        End If
        RptDetailCusWhere = Nothing
    End Sub

    Private Sub setRptPart3(ByVal RptMaster As IList(Of AMLO101))
        Dim dteDateSpil As String() = Nothing
        Dim blnChkTotaShow As Boolean = True
        Dim testStr As String = ""
        Dim dte_date As Date = Nothing

        Try
            dteDateSpil = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, RptMaster(0).TRANSDATE).Split("/")
            dte_date = RptMaster(0).TRANSDATE
            testStr = dte_date.ToString("MMMM")

            lblTransDate_Day.Text = dteDateSpil(0)
            lblTransDate_Month.Text = testStr
            lblTransDate_Year.Text = dteDateSpil(2)

        Catch ex As Exception

        End Try

        'ฝั่งฝากเงิน
        Try
            If (CInt(RptMaster(0).TRANSTYPE).ToString = "1") Then
                lblTransType01.Text = "x"
                lblAccountNoDeposit1.Text = RptMaster(0).ACCOUNTNO
                'lblAccountNoDeposit1.Text = subStringText(RptMaster(0).ACCOUNTNO, 1)
                'lblAccountNoDeposit2.Text = subStringText(RptMaster(0).ACCOUNTNO, 2)
                'lblAccountNoDeposit3.Text = subStringText(RptMaster(0).ACCOUNTNO, 3)
                'lblAccountNoDeposit4.Text = subStringText(RptMaster(0).ACCOUNTNO, 4)
                'lblAccountNoDeposit5.Text = subStringText(RptMaster(0).ACCOUNTNO, 5)
                'lblAccountNoDeposit6.Text = subStringText(RptMaster(0).ACCOUNTNO, 6)
                'lblAccountNoDeposit7.Text = subStringText(RptMaster(0).ACCOUNTNO, 7)
                'lblAccountNoDeposit8.Text = subStringText(RptMaster(0).ACCOUNTNO, 8)
                'lblAccountNoDeposit9.Text = subStringText(RptMaster(0).ACCOUNTNO, 9)
                'lblAccountNoDeposit10.Text = subStringText(RptMaster(0).ACCOUNTNO, 10)
                lblTransAmt01.Text = insertComma(RptMaster(0).TRANSAMT)
                blnChkTotaShow = False
            End If

            If (CInt(RptMaster(0).TRANSTYPE).ToString = "3") Then
                lblTransType01.Text = "x"
                lblAccountNoRefDeposit1.Text = RptMaster(0).ACCOUNTNO
                'lblAccountNoRefDeposit1.Text = subStringText(RptMaster(0).ACCOUNTNO, 1)
                'lblAccountNoRefDeposit2.Text = subStringText(RptMaster(0).ACCOUNTNO, 2)
                'lblAccountNoRefDeposit3.Text = subStringText(RptMaster(0).ACCOUNTNO, 3)
                'lblAccountNoRefDeposit4.Text = subStringText(RptMaster(0).ACCOUNTNO, 4)
                'lblAccountNoRefDeposit5.Text = subStringText(RptMaster(0).ACCOUNTNO, 5)
                'lblAccountNoRefDeposit6.Text = subStringText(RptMaster(0).ACCOUNTNO, 6)
                'lblAccountNoRefDeposit7.Text = subStringText(RptMaster(0).ACCOUNTNO, 7)
                'lblAccountNoRefDeposit8.Text = subStringText(RptMaster(0).ACCOUNTNO, 8)
                'lblAccountNoRefDeposit9.Text = subStringText(RptMaster(0).ACCOUNTNO, 9)
                'lblAccountNoRefDeposit10.Text = subStringText(RptMaster(0).ACCOUNTNO, 10)
                lblTransAmt03.Text = insertComma(RptMaster(0).TRANSAMT)
                blnChkTotaShow = False

            End If


            'ฝั่งถอนเงิน
            If (CInt(RptMaster(0).TRANSTYPE).ToString = "2") Then
                lblTransType02.Text = "x"
                lblAccountNoWithdraw1.Text = RptMaster(0).ACCOUNTNO
                'lblAccountNoWithdraw1.Text = subStringText(RptMaster(0).ACCOUNTNO, 1)
                'lblAccountNoWithdraw2.Text = subStringText(RptMaster(0).ACCOUNTNO, 2)
                'lblAccountNoWithdraw3.Text = subStringText(RptMaster(0).ACCOUNTNO, 3)
                'lblAccountNoWithdraw4.Text = subStringText(RptMaster(0).ACCOUNTNO, 4)
                'lblAccountNoWithdraw5.Text = subStringText(RptMaster(0).ACCOUNTNO, 5)
                'lblAccountNoWithdraw6.Text = subStringText(RptMaster(0).ACCOUNTNO, 6)
                'lblAccountNoWithdraw7.Text = subStringText(RptMaster(0).ACCOUNTNO, 7)
                'lblAccountNoWithdraw8.Text = subStringText(RptMaster(0).ACCOUNTNO, 8)
                'lblAccountNoWithdraw9.Text = subStringText(RptMaster(0).ACCOUNTNO, 9)
                'lblAccountNoWithdraw10.Text = subStringText(RptMaster(0).ACCOUNTNO, 10)
                lblTransAmt02.Text = insertComma(RptMaster(0).TRANSAMT)

            End If

            If (CInt(RptMaster(0).TRANSTYPE).ToString = "4") Then
                lblTransType02.Text = "x"
                lblAccountNoRefWithdraw1.Text = RptMaster(0).ACCOUNTNO
                'lblAccountNoRefWithdraw1.Text = subStringText(RptMaster(0).ACCOUNTNO, 1)
                'lblAccountNoRefWithdraw2.Text = subStringText(RptMaster(0).ACCOUNTNO, 2)
                'lblAccountNoRefWithdraw3.Text = subStringText(RptMaster(0).ACCOUNTNO, 3)
                'lblAccountNoRefWithdraw4.Text = subStringText(RptMaster(0).ACCOUNTNO, 4)
                'lblAccountNoRefWithdraw5.Text = subStringText(RptMaster(0).ACCOUNTNO, 5)
                'lblAccountNoRefWithdraw6.Text = subStringText(RptMaster(0).ACCOUNTNO, 6)
                'lblAccountNoRefWithdraw7.Text = subStringText(RptMaster(0).ACCOUNTNO, 7)
                'lblAccountNoRefWithdraw8.Text = subStringText(RptMaster(0).ACCOUNTNO, 8)
                'lblAccountNoRefWithdraw9.Text = subStringText(RptMaster(0).ACCOUNTNO, 9)
                'lblAccountNoRefWithdraw10.Text = subStringText(RptMaster(0).ACCOUNTNO, 10)
                lblTransAmt04.Text = insertComma(RptMaster(0).TRANSAMT)
            End If

        Catch ex As Exception

        End Try


        'ชื่อตราสารการเงิน
        Try
            If (CInt(RptMaster(0).TRANSTYPE).ToString = "5") Then
                lblTranTypeBuy.Text = "x"
                lblTransType05.Text = "x"
                lblAccTransType05.Text = RptMaster(0).ACCOUNTNO
                lblTransAmt05.Text = insertComma(RptMaster(0).TRANSAMT)
                blnChkTotaShow = False
            ElseIf (CInt(RptMaster(0).TRANSTYPE).ToString = "7") Then
                lblTranTypeBuy.Text = "x"
                lblTransType07.Text = "x"
                lblAccTransType07.Text = RptMaster(0).ACCOUNTNO
                lblTransAmt07.Text = insertComma(RptMaster(0).TRANSAMT)
                blnChkTotaShow = False
            ElseIf (CInt(RptMaster(0).TRANSTYPE).ToString = "9") Then
                lblTranTypeBuy.Text = "x"
                lblTransType09.Text = "x"
                lblTransType09_Other.Text = RptMaster(0).TRANSTYPEOTHER
                lblTransAmt09.Text = insertComma(RptMaster(0).TRANSAMT)
                blnChkTotaShow = False
            End If


            'ขายตราสารการเงิน
            If (CInt(RptMaster(0).TRANSTYPE).ToString = "6") Then
                lblTranTypeSell.Text = "x"
                lblTransType06.Text = "x"
                lblAccTransType06.Text = RptMaster(0).ACCOUNTNO
                lblTransAmt06.Text = insertComma(RptMaster(0).TRANSAMT)
            ElseIf (CInt(RptMaster(0).TRANSTYPE).ToString = "8") Then
                lblTranTypeSell.Text = "x"
                lblTransType08.Text = "x"
                lblAccTransType08.Text = RptMaster(0).ACCOUNTNO
                lblTransAmt08.Text = insertComma(RptMaster(0).TRANSAMT)
            ElseIf (CInt(RptMaster(0).TRANSTYPE).ToString = "10") Then
                lblTranTypeSell.Text = "x"
                lblTransType10.Text = "x"
                lblTransType10_Other.Text = RptMaster(0).TRANSTYPEOTHER
                lblTransAmt10.Text = insertComma(RptMaster(0).TRANSAMT)
            End If





            'ซื้่อเงินตราต่างประเทศ
            If (CInt(RptMaster(0).TRANSTYPE).ToString = "11") Then
                lblTransType11.Text = "x"
                lblTransAmt11.Text = insertComma(RptMaster(0).TRANSAMT)
                blnChkTotaShow = False
            End If


            'ขายเงินตราต่างประเทศ
            If (CInt(RptMaster(0).TRANSTYPE).ToString = "12") Then
                lblTransType12.Text = "x"
                lblTransAmt12.Text = insertComma(RptMaster(0).TRANSAMT)
            End If


            'อื่นๆ ฝั่งซ้าย
            If (CInt(RptMaster(0).TRANSTYPE).ToString = "98") Then
                lblTransType98.Text = "x"
                lblTransType98_Other.Text = RptMaster(0).TRANSTYPEOTHER
                If (RptMaster(0).TRANSTYPEOTHER.Length > 18) Then
                    lblTransType98_Other.Font.Size = FontSize.Small
                End If

                lblTransAmt98.Text = insertComma(RptMaster(0).TRANSAMT)
                blnChkTotaShow = False
            End If


            'อื่นๆ ฝั่งขวา
            If (CInt(RptMaster(0).TRANSTYPE).ToString = "99") Then
                lblTransType99.Text = "x"
                lblTransType99_Other.Text = RptMaster(0).TRANSTYPEOTHER
                If (RptMaster(0).TRANSTYPEOTHER.Length > 18) Then
                    lblTransType99_Other.Font.Size = FontSize.Small
                End If
                lblTransAmt99.Text = insertComma(RptMaster(0).TRANSAMT)
            End If

        Catch ex As Exception

        End Try

        If (blnChkTotaShow = False) Then
            'รวมฝั่งซ้าย
            lblTransAmtTotalLeft.Text = insertComma(RptMaster(0).TRANSAMT)
            lblTransAmtChar1.Text = RptMaster(0).TRANSAMTCHAR
        Else
            'รวมฝั่งขวา
            lblTransAmtTotalRight.Text = insertComma(RptMaster(0).TRANSAMT)
            lblTransAmtChar2.Text = RptMaster(0).TRANSAMTCHAR

        End If





        'ส่วนของผู้ได้รับผลประโยชน์

        Try
            If (RptMaster(0).GAINMIDNAME = "-") Then
                lblGainFullName.Text = RptMaster(0).GAINFIRSTNAME & " " & RptMaster(0).GAINLASTNAME
            Else
                lblGainFullName.Text = RptMaster(0).GAINFIRSTNAME & " " & RptMaster(0).GAINMIDNAME & " " & RptMaster(0).GAINLASTNAME
            End If
        Catch ex As Exception
            lblGainFullName.Text = RptMaster(0).GAINFIRSTNAME & " " & RptMaster(0).GAINLASTNAME
        End Try

        'If (RptMaster(0).OBJBIZ = 1) Then
        '    lblObjName.Text = "ฝากเงินเพื่อรับดอกเบี้ย"
        'ElseIf (RptMaster(0).OBJBIZ = 2) Then
        '    lblObjName.Text = "ถอนไปใช้ในธุรกิจ"
        'ElseIf (RptMaster(0).OBJBIZ = 3) Then
        '    lblObjName.Text = "ซื้อเช็คจ่ายสินค้า"
        'ElseIf (RptMaster(0).OBJBIZ = 4) Then
        '    lblObjName.Text = "จดจำนองหลักประกันของสินเชื่อ"
        'ElseIf (RptMaster(0).OBJBIZ = 5) Then
        '    lblObjName.Text = "ไถ่ถอนจดจำนอง"
        'ElseIf (RptMaster(0).OBJBIZ = 6) Then
        '    lblObjName.Text = "ชำระหนี้"
        'ElseIf (RptMaster(0).OBJBIZ = 7) Then
        '    lblObjName.Text = "มรดก"
        'ElseIf (RptMaster(0).OBJBIZ = 8) Then
        '    lblObjName.Text = "แลกเปลี่ยนทางธุรกิจ"
        'ElseIf (RptMaster(0).OBJBIZ = 9) Then
        '    lblObjName.Text = "ให้เป็นของขวัญ"
        'ElseIf (RptMaster(0).OBJBIZ = 10) Then
        '    lblObjName.Text = "ซื้อเพื่อที่อยู่อาศัย"
        'ElseIf (RptMaster(0).OBJBIZ = 98) Then
        '    lblObjName.Text = "ไม่ระบุวัตถุประสงค์"
        'ElseIf (RptMaster(0).OBJBIZ = 99) Then
        '    lblObjNameOther.Text = RptMaster(0).OBJBIZOTHER
        'Else

        'End If

        If (RptMaster(0).OBJBIZ Is Nothing) Then
            lblObjNameOther.Text = ""
        ElseIf (RptMaster(0).OBJBIZ = 99) Then
            lblObjNameOther.Text = RptMaster(0).OBJBIZOTHER
        Else
            lblObjNameOther.Text = clsMasterDropDown.getObjTypeName_AMLO101(AmloEntity, RptMaster(0).OBJBIZ)
        End If


        'สถาบันการเงินเป็นผู้บันทึกข้อเท็จจริง
        If (RptMaster(0).SAVETYPE = 1) Then
            lblSaveType.Text = "x"

        End If

        'ลูกค้าไม่ลงลายมือชื่อ
        If (RptMaster(0).SIGNTYPE = 0) Then
            lblSignType.Text = "x"
        End If


        Try
            If (RptMaster(0).SAVEDATE Is Nothing) Then
                lblSaveDate.Text = clsDateFormat.chkDateThOrEn(clsDateFormat.enmDateCultureInfo.Th, RptMaster(0).SAVEDATE)
            End If

        Catch ex As Exception

        End Try


    End Sub

    Private Function subStringText(ByVal strText As String, ByVal intPosition As Integer) As String
        Try
            Dim strPositionSub As String = ""
            Dim intTextLength As Int32 = 0
            If Not (strText = "") Then
                intTextLength = strText.Length
                If (intPosition < intTextLength) Then
                    strPositionSub = strText.Substring(intPosition - 1, 1)
                ElseIf (intPosition = intTextLength) Then
                    strPositionSub = strText.Substring(intPosition - 1)
                Else
                    strPositionSub = ""
                End If
            Else
                strPositionSub = ""
            End If

            Return strPositionSub
        Catch ex As Exception
            Throw ex
        End Try

    End Function

    Private Function insertComma(ByVal strTransAmt As String) As String
        Dim dcmMoney As Decimal
        Try
            dcmMoney = strTransAmt
            strTransAmt = Decimal.Parse(strTransAmt).ToString("N2")
        Catch ex As Exception
            Throw ex
        End Try
        Return strTransAmt
    End Function
End Class
